package com.hnkywl.sts.service.report;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hnkywl.sts.dao.report.YqyskDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: ccr
 * Date: 13-7-16
 * Time: 下午2:23
 * To change this template use File | Settings | File Templates.
 */
@Service
public class YqyskService {
    private YqyskDao yqyskDao;

    public String yqyskList(Long gsId,Long bmId,Date startDate,Date endDate){
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Map<String, List> map = yqyskDao.ysktjList(1,gsId, bmId, startDate, endDate);
        List<Map> grid = map.get("rows") == null ? new ArrayList<Map>() : map.get("rows");
        List<Map> footer = map.get("footer") == null ? new ArrayList<Map>() : map.get("footer");
        return "{\"rows\":"+gson.toJson(grid)+",\"footer\":"+gson.toJson(footer)+"}";
    }

    @Autowired
    public void setYqyskDao(YqyskDao yqyskDao) {
        this.yqyskDao = yqyskDao;
    }
}
